<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台（PHP版）
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码，建议反馈是我们前进的动力
// | 开源版本可自由商用，可去除界面版权logo
// | gitee下载：https://gitee.com/likeshop_gitee/likeadmin
// | github下载：https://github.com/likeshop-github/likeadmin
// | 访问官网：https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------

namespace app\api\controller;

use app\api\lists\AccountLogLists;
use app\common\model\article\Vip;
use app\common\model\qualifications\Qualifications;
use app\common\model\user\User;

/**
 * 账户流水
 * Class AccountLogController
 * @package app\api\controller
 */
class QualificationsController extends BaseApiController
{
   public  function lists(){
       return $this->success('操作成功', ['data' => Qualifications::lists()], 1, 1);
   }

    public  function detail(){
      $perms= $this->request->get();
        return $this->success('操作成功', ['data' => Qualifications::detail($perms['id'])], 1, 1);
    }
    public  function edit(){
        $perms= $this->request->post();
        return $this->success('操作成功', ['data' => Qualifications::edit($perms)], 1, 1);
    }
    public  function add(){
        $perms= $this->request->post();
        $perms['user_id']=$this->userId;
   $pd=  Qualifications::detailu($perms['user_id']);
   if ($pd){
       return $this->success('操作失败已有申请', ['data' =>0 ], 1, 1);
   }
      $list = (new User())->where("id","=", $perms['user_id'])->update(["qualifications"=>2]);

        Qualifications::add($perms);
      if ($list){
          return $this->success('操作成功', ['data' =>1 ], 1, 1);
      }
        return $this->success('操作失败', ['data' => 2], 1, 1);

    }
}